package com.isp.org.server.domain.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isp.common.model.vo.Result;
import com.isp.org.api.dto.Resource;
import com.isp.org.api.dto.menu.SysMenu;
import com.isp.org.api.dto.user.SysUserId;
import com.isp.org.server.domain.entity.MenuEntity;
import com.isp.org.server.domain.mapper.MenuMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * @author linsy
 * @version 1.0
 * @created 2024/3/12 16:48
 */
@Service
@RequiredArgsConstructor
public class MenuService extends ServiceImpl<MenuMapper, MenuEntity> {

    private final MenuMapper menuMapper;

    public List<SysMenu> findMenusByType(String app, Integer type) {
        return menuMapper.findMenusByType(app, type);
    }

    public void deleteById(String id) {
        this.removeById(id);
    }

    public List<SysMenu> findByUserId(String app, Long userId, Integer type, Boolean present) {
        return menuMapper.findByUserId(app, userId, type, present);
    }

    public SysMenu findByCode(String app, String code) {
        return menuMapper.findByCode(app, code);
    }

    public SysMenu findByUrlAndMethod(String app, String url, String urlMethod) {
        return menuMapper.findByUrlAndMethod(app, url, urlMethod);
    }

    public List<SysUserId> findUserByMenuUrl(String url, String urlMethod) {
        return menuMapper.findUserByMenuUrl(url, urlMethod);
    }

    public Set<Resource> findAllByType(Integer type) {
        return menuMapper.findAllByType(type);
    }

    public Set<Resource> queryInRoleIdAndType(Set<Long> roleIds, Integer menuType) {
        return menuMapper.queryInRoleIdAndType(roleIds, menuType);
    }
}
